﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

class Student
{
    private string fName;
    private string lName;
    private int fN;
    private string tel;
    private string email;
    private List<int> marks;
    private int gNumb;
    private int gr;
    private const string emailPattern = @"\A[a-zA-Z0-9]+[a-zA-Z0-9\._]*@[a-zA-Z0-9]+.([a-zA-Z0-9]+\.)*[a-zA-Z]{2,4}\Z";
    private const string telPattern = @"\A[0-9\s-]+\Z";

    public Student(string fName, string lName, int fN, string tel, string email, List<int> marks, int gNumb, int gr)
    {
        this.marks = new List<int>();
        this.FName = fName;
        this.LName = lName;
        this.FN = fN;
        this.Tel = tel;
        this.Email = email;
        this.Marks = marks;
        this.GNumb = gNumb;
        this.Gr = gr;
    }

    public string FName
    {
        get
        {
            return fName;
        }
        set
        {
            if (value != null && value != "")
            {
                fName = value;
            }
            else
            {
                throw new ArgumentException("Invalid First Name");
            }
        }
    }
    public string LName
    {
        get
        {
            return lName;
        }
        set
        {
            if (value != null && value != "")
            {
                lName = value;
            }
            else
            {
                throw new ArgumentException("Invalid Last Name");
            }
        }
    }
    public int FN
    {
        get
        {
            return fN;
        }
        set
        {
            if (value > 0)
            {
                fN = value;
            }
            else
            {
                throw new ArgumentException("Invalid Faculty Number");
            }
        }
    }
    public string Tel
    {
        get
        {
            return tel;
        }
        set
        {
            Regex reg = new Regex(telPattern);
            if (value != null && value != "" && reg.IsMatch(value))
            {
                tel = value;
            }
            else
            {
                throw new ArgumentException("Invalid Tellephone Number");
            }
        }
    }
    public string Email
    {
        get
        {
            return email;
        }
        set
        {
            Regex reg = new Regex(emailPattern);
            if (value != null && value != "" && reg.IsMatch(value))
            {
                email = value;
            }
            else
            {
                throw new ArgumentException("Invalid Email Address");
            }
        }
    }
    public List<int> Marks
    {
        get
        {
            List<int> tmp = new List<int>();
            foreach (int mark in marks)
            {
                tmp.Add(mark);
            }
            return tmp;
        }
        set
        {
            if (value != null)
            {
                foreach (int mark in value)
                {
                    marks.Add(mark);
                }
            }
            else
            {
                throw new ArgumentException("Invalid Marks");
            }
        }
    }
    public int GNumb
    {
        get
        {
            return gNumb;
        }
        set
        {
            if (value > 0 && value < 20)
            {
                gNumb = value;
            }
            else
            {
                throw new ArgumentException("Invalid Group Number");
            }
        }
    }
    public int Gr
    {
        get
        {
            return gr;
        }
        set
        {
            gr = value;
        }
    }

    public override string ToString()
    {
        return string.Format("{0} {1} FactNum: {2}, Tel: {3}, Email: {4}, GroupNum: {5}", fName, lName, fN, tel, email, gNumb);
    }

}

